<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Path</title>
</head>

<body>
    <!-- 定义Canvas画布 -->
    <canvas id="myCanvas" width="300" height="300" style="border: 1px solid black"></canvas>
    <script>
        // 访问Canvas画布元素
        var canvas = document.getElementById("myCanvas");
        var ctx = canvas.getContext("2d");
        // 1.一条直线
        ctx.beginPath();
        ctx.moveTo(40, 40);
        ctx.lineTo(240, 40);
        ctx.stroke();

        // 2.创建一个圆形
        ctx.beginPath();
        ctx.arc(80, 100, 50, 0, Math.PI * 2, false);
        ctx.closePath();
        ctx.fillStyle = "blue";
        ctx.fill();

        // // 3.画一条曲线
        ctx.beginPath();
        ctx.moveTo(200, 20);
        ctx.bezierCurveTo(80, 20, 80, 100, 150, 100);
        ctx.stroke();
    </script>
</body>

</html>